package com.wyd.resourcetj.dao;

import java.util.List;

import javax.transaction.Transactional;

import com.wyd.resourcetj.model.Member;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * IMemberDao
 */
public interface IMemberDao extends JpaRepository<Member, Integer>,JpaSpecificationExecutor<Member> {

    @Transactional
    @Modifying
   // @Query("update Users u set u.uname = ?2 where u.uid= ?1")  示例
    @Query("update Member m set m.name = :name,m.sex = :sex,m.category = :category,m.swpartment = :swpartment,m.profession = :profession,m.grade = :grade,m.phone = :phone,m.remark = :remark where m.id= :id")
    
    int editMember(Integer id,String name,String sex,String category,String swpartment,String profession,String grade,String phone,String remark);


   /*  @Transactional     //逻辑删除
    @Modifying
   // @Query("update Users u set u.uname = ?2 where u.uid= ?1")  示例
    @Query("update Member m set m.exist = :exist where m.id= :id")
    
    int deleteMember(Integer id,Integer exist); */

     //查询状态正常的所有会员信息
    @Query("select m from Member m where m.status = :status")
    Member getAllMember(Integer status);

    //根据卡号查询状态
    
    @Query("select m from Member m where m.card_no = :card_no")
    Member getCardStatus(String card_no);

    //根据卡号修改卡号状态
   /*  @Transactional
    @Modifying
    @Query(" update Member m set m.status = :status where m.card_no= :card_no")
    int updateStatus(String card_no,Integer status); */


    //批量删除
    @Modifying
    @Transactional
    @Query("delete from Member m where m.id in (?1)")
    void deleteMoreMember(List<Integer> ids);
    


}
